package one.stand.service;

import com.alibaba.fastjson.JSON;
import one.stand.OneUserServiceApplicationTests;
import one.stand.entity.WxNoticeEntity;
import one.stand.enums.LoginEnum;
import one.stand.enums.WxNoticeEnums;
import one.stand.model.OrdersModel;
import one.stand.model.ResultModel;
import one.stand.request.OrderinfoRequest;
import one.stand.request.OrdersRequest;
import one.stand.request.ShopcartRequest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.*;

public class Order extends OneUserServiceApplicationTests {
    @Autowired
    OrdersService ordersService;
    @Autowired
    WxPayService wxPayService;

    transient String sf = "";

    @Test
    public void addShopcart(){

        OrdersModel model = new OrdersModel();
        model.setOrdersId(279);
        model.setOrdersNo("YL15596370941815837");
        model.setOrderPrice(100);
        //ordersService.test(model);

        int i = 0;
        for(int ii = 0 ; i < 9 ; i++){
        }

        for(String ss : new String[]{}){
        }

        LocalDateTime midnight = LocalDateTime.now().plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
        long seconds = ChronoUnit.SECONDS.between(LocalDateTime.now(), midnight);
        System.err.println(seconds);

        Date date;
        java.sql.Date date1 = new java.sql.Date(1);
        date = new Date(date1.getTime());
        date = new Date(date.getTime());
        List list = new ArrayList();
        List list1 = new LinkedList();
        Map map = new HashMap<>();

        ShopcartRequest request = new ShopcartRequest();
        request.setSpecId(273);
        request.setGoodsId(72);
        request.setId(121L);
        request.setCardId(277);
        request.setNum(2);
        request.setForwardId(121);
        //System.err.println(JSON.toJSON(ordersService.addShopcart(request)));
    }

    @Test
    public void pay(){
        OrdersRequest request=new OrdersRequest();
        request.setOrdersId(1);
        System.err.println(JSON.toJSON(ordersService.goPay(request)));
    }

    @Test
    public void doReminder(){
        OrdersRequest request = new OrdersRequest();
        request.setOrdersId(254);
        System.err.println(JSON.toJSON(ordersService.doReminder(request)));
    }

    @Test
    public void companyRoyaltyNew() {
        // 分销金额提成 (确认收货时调用) （3.2版本迭代）
        ordersService.companyRoyaltyNew(279, "118.113.212.41", "one-stand");
    }

    @Test
    public void companyRoyalty() throws Exception {


        System.err.println(wxPayService.wxPay("商品购买","YL15591143309955971","1","ouWx45HI53kaxU2tQaz3F8GFCukA","118.116.121.116",266,"one-stand").toString());

        //System.err.println(wxPayService.doCash("TX123465789", "ouWx45GJkktRpzT8IGNMUO6yvdfc", 100, "171.88.42.11", "one-stand").getMessage());
    }

    @Test
    public void goPayNew() {

        OrdersRequest request = new OrdersRequest();
        request.setId(121L);
        request.setAddressId(29);
        request.setRemark("这是我的新订单哦");
        request.setIp("171.88.42.11");
        request.setCompanyKey("one-stand");
        List<OrderinfoRequest> list = new ArrayList<>();
        OrderinfoRequest orderinfoRequest = new OrderinfoRequest();
        orderinfoRequest.setGoodsId(122);
        orderinfoRequest.setSpecId(517);
        orderinfoRequest.setNum(2);
        orderinfoRequest.setCardId(590);
        list.add(orderinfoRequest);
        OrderinfoRequest orderinfoRequest1 = new OrderinfoRequest();
        orderinfoRequest1.setGoodsId(122);
        orderinfoRequest1.setSpecId(521);
        orderinfoRequest1.setNum(3);
        orderinfoRequest1.setCardId(590);
        list.add(orderinfoRequest1);
        request.setOrderinfoRequestList(list);
        System.err.println(JSON.toJSONString(request));
        //System.err.println(ordersService.goPayNew(request).getMessage());
    }
    @Test
    public void doCash() throws Exception {
        System.err.println(wxPayService.doCash("YL123456","ouWx45GJkktRpzT8IGNMUO6yvdfc",100,"171.221.170.109","one-stand"));
    }
}
